package logic

import (
	"context"
	"google.golang.org/grpc/codes"
	"google.golang.org/grpc/status"
	"user_srv/model"
	"user_srv/user_proto"
)

func (s *Server) GetUserByMobile(ctx context.Context, in *user_proto.GetUserByMobileRequest) (*user_proto.UserInfo, error) {
	info, err := model.GetUserInfo(in.Mobile)
	if err != nil {
		return nil, status.Error(codes.Internal, "查询用户信息失败")
	}
	return &user_proto.UserInfo{
		Id:       int64(info.ID),
		Mobile:   info.Mobile,
		Password: info.Password,
		NickName: info.NickName,
		BirthDay: info.BirthDay,
		Sex:      int64(info.Sex),
		Age:      int64(info.Age),
	}, nil
}
